<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>

</body>
<script>
  // 去除字符串中的空格
  function handleStr(str){
    console.log(str,'0000')
    // const arr = str.split('')
    // const newArr = arr.filter(ele => ele!==' ')
    // return newArr.join('')

    // let newStr = ''
    // for(let i=0; i<str.length;i++){
    //   if(str[i]!==' ') newStr+=str[i]
    // }
    // return newStr

    // return str.replace(/\s+/g, '')

    // return str.replace(/^\s+/, '')

    return str.replace(/\s+$/, '')

    // return str.replace(/\s+/, '')
  }
  console.log(handleStr('   123 4 5 67 89 sdfs  '),'0000','9999')
</script>
</html>
